from pythonds.basic.deque import Deque


def huiwen(string):
    flag = True
    suangdeque = Deque()
    for i in string:
        suangdeque.addRear(i)

    while suangdeque.size() > 1 and flag:
        font = suangdeque.removeFront()
        rear = suangdeque.removeRear()
        if font == rear:
            continue
        else:
            flag = False
    return flag


print(huiwen('上海自来水来自海上'))

from pythonds.basic.deque import Deque


def palchecker(aString):
    chardeque = Deque()
    for ch in aString:
        chardeque.addRear(ch)
    stillEqual = True

    while chardeque.size() > 1 and stillEqual:
        first = chardeque.removeFront()
        last = chardeque.removeRear()
        if first != last:
            stillEqual = False
    return stillEqual


print(palchecker('lsdkjfskf'))
print(palchecker('上海自来水来自海上'))


def list_huiwen(aString):
    flag = True
    alist = list(aString)
    for i in range(len(alist) // 2):
        if alist[i] != alist[-1 - i]:
            flag = False
            break
    return flag


print(list_huiwen('上海自来水来自海上'))
